public class HeapTester {

  public static void main(String args[]){
    if (args.length == 1) 
      Terminal.startTranscript(args[0]);

    // comment this out if you instead want to use command line arguments
    Terminal.startTranscript("heapTester-output");
    BinaryHeap h = new BinaryHeap(5);
    BinaryHeap.Tracker[] trackers = new BinaryHeap.Tracker[5];
	
    trackers[0] = h.insert(7.5,"a");
    trackers[1] = h.insert(10.1,"b");
    trackers[2] = h.insert(5.25,"c");
    Terminal.print("After inserting 7.5 (data a), 10.1 (data b), 5.25 (data c),");
    Terminal.println(" the heap is:\n" + h);
    trackers[3] = h.insert(4.1,"d");
    Terminal.println("After inserting 4.1 (data d), the heap is:\n" + h);
    trackers[4] = h.insert(2.05,"e");
    Terminal.println("After inserting 2.05 (data e), the heap is:\n" + h);

    Terminal.println("decreasing key for trackers[0] (which is node with key 7.5) to 3.3");
    if (trackers[0].decreaseKey(3.3))
      Terminal.println("The key was decreased");
    else
      Terminal.println("The key was not decreased");
    Terminal.println("The heap is:\n" + h);

    Terminal.println("decreasing key for trackers[1] (which is node with key 10.1) to 1.5");
    if (trackers[1].decreaseKey(1.5))
      Terminal.println("The key was decreased");
    else
      Terminal.println("The key was not decreased");
    Terminal.println("The heap is:\n" + h);

    Terminal.println("decreasing key for trackers[3] (which isnode with key 4.1) to 5.15");
    if (trackers[3].decreaseKey(5.15))
      Terminal.println("The key was decreased");
    else
      Terminal.println("The key was not decreased");

    for (int i=0; i < 4; i++){
      Terminal.println("Removing the key " + h.minimumKey());
      Terminal.println("   it had data " + h.extractMinData());
      Terminal.println("The heap is:\n" + h);
    }
  }

}
